import SwiftUI

struct BackdropView: UIViewRepresentable {
    
    func makeUIView(context: Context) -> UIVisualEffectView {
        let view = UIVisualEffectView(effect: UIBlurEffect())
        return view
    }
    
    func updateUIView(_ uiView: UIVisualEffectView, context: Context) { }
    
}

struct BackdropBlurView: View {
    
    let radius: CGFloat
    
    @ViewBuilder
    var body: some View {
        ZStack {
            BackdropView()
                .blur(radius: radius)
                .edgesIgnoringSafeArea(.bottom)
            
            // 更柔和的渐变效果，调整透明度更细腻
            LinearGradient(
                gradient: Gradient(colors: [Color("BgColor1").opacity(0.5), Color("BgColor1").opacity(0)]),
                startPoint: .top,
                endPoint: .bottom
            )
            .frame(height: 120)  // 控制渐变的高度
            .edgesIgnoringSafeArea(.bottom)
        }
    }
}

#Preview {
    BackdropBlurView(radius: 10)
}

